package com.sun.controller.front;


import com.sun.pojo.Floor;
import com.sun.pojo.Room;
import com.sun.pojo.RoomType;
import com.sun.service.FloorService;
import com.sun.service.RoomService;
import com.sun.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class HomeController {

    @Autowired
    private RoomTypeService roomTypeService;
    @Autowired
    private FloorService floorService;
    @Autowired
    private RoomService roomService;

    @RequestMapping("/home.html")
    public String home(Model model){
        // 初始化首页房型选项
        List<RoomType> roomTypeList = roomTypeService.initRoomTypeSelectForHome();
        // 获取所有楼层
        List<Floor> floorList = floorService.initAll();
        // 获取房间数据
        List<Room> roomList=roomService.initAll();

        model.addAttribute("roomTypeList",roomTypeList);
        model.addAttribute("floorList",floorList);
        model.addAttribute("roomList",roomList);
        return "front/home";
    }
}
